package io.wongxd.demo.page

import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import io.wongxd.demo.M
import io.wongxd.demo.page.views.*
import io.wongxd.solution.baseView.AtyContainer
import io.wongxd.solution.baseView.BaseComposeFragment
import io.wongxd.solution.baseView.BaseComposeToolBarFgt
import kotlin.reflect.KClass

class FgtViews : BaseComposeToolBarFgt() {
    override fun lazyInit() {

    }

    override val title: String
        get() = "views"

    private val buttons = listOf(
        "rv的基础功能" to FgtViewMain::class,
        "ViewPager功能" to FgtViewPager::class,
        "Banner功能" to FgtViewBanner::class,
        "PagerIndicator功能" to FgtViewPageIndicator::class,
        "TextPagerIndicator功能" to FgtViewTextIndicator::class,
        "FlowLayout功能" to FgtViewFlowLayout::class,
        "TextField功能" to FgtViewTextFiled::class,
        "MenuFab功能" to FgtViewMenuFab::class,
        "RefreshLayout功能" to FgtViewRefreshLayout::class,
        "ScrollableAppBar功能" to FgtViewScrollableAppBar::class,
        "SwipeToDismiss功能" to FgtViewSwipeToDismiss::class,
        "ValueSelector功能" to FgtViewValueSelector::class,
    )


    @Composable
    override fun Render() {
        LazyColumn(modifier = M.fillMaxSize()) {
            items(buttons) {
                Button(
                    onClick = { jump(it.second) }
                ) {
                    Text(text = it.first)
                }
            }
        }
    }

    private fun jump(fgtClas: KClass<out BaseComposeToolBarFgt>) {
        AtyContainer.startFgt(requireContext(), fgtClas.java.newInstance())
    }

    @Preview(showBackground = true, backgroundColor = 0xffffffff)
    @Composable
    fun RenderPreView() {

    }
}